﻿<%@ Page Language="C#" CodeBehind="Add.aspx.cs" Inherits="WinnerCMS.WebUI.Admin.Vote.Add" %>

<%@ Register Src="../UC_AjaxLoading.ascx" TagName="UC_AjaxLoading" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html>
<head runat="server">
    <title>添加投票</title>
    <meta http-equiv="Pragma" content="No-cach" />
    <%: Styles.Render("~/Content/Bootstrap/css") %>
    <%: Scripts.Render("~/Scripts/AdminBase") %>
    <style type="text/css">
        .RowTitle
        {
            width: 110px;
        }
    </style>
    <script type="text/javascript">
        var Row = $("#ChoiceList #trSource");
        $(document).ready(function () {
            Row = $("#ChoiceList #trSource");

            $('#txtEndData').datepicker({
                format: "yyyy-mm-dd",
                startDate: "1998-1-01",
                endDate: "2030-1-01",
                language: "zh-CN", autoclose: true
            });
        });
        function AddChoice() {
            var tr = Row.clone(true);
            tr.attr("id", "");
            tr.appendTo("#ChoiceList");
        }
        function LoadChoice(id, choiceTitle, voteNum) {
            var tr = Row.clone(false, false);
            tr.find("input[name='hfID']").val(id);
            tr.find("input[name='txtChoiceTitle']").val(choiceTitle);
            tr.find("input[name='NtxtVoteNum']").val(voteNum);
            var btnDel = tr.find("input[name='btnDel']")[0];
            btnDel.onclick = function () { return DeleteChoice(id, this); };

            tr.attr("id", "");
            tr.appendTo("#ChoiceList");
        }

        function DeleteChoice(ID, obj) {
            if (confirm('您确定要删除？') == false) {
                return false;
            }
            if (obj.parentNode.parentNode.tagName == "TR") {
                if (ID > 0) {
                    $.ajax({
                        type: "POST",
                        url: "AjaxPostBack.ashx?Action=DeleteChoice",
                        data: "ID=" + ID,
                        beforeSend: function () {
                        },
                        success: function (info) {
                            var TR = obj.parentNode.parentNode;
                            TR.parentNode.removeChild(TR);
                        }
                    });

                } else {
                    var tr = obj.parentNode.parentNode;
                    tr.parentNode.removeChild(tr);
                }
            }
            return true;
        }

        function CheckChoceTitle(obj) {
            var str = obj.value;
            obj.value = str.replace(",", "，");
        }
 
    </script>
</head>
<body>
    <form id="Form1" method="post" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
        <ProgressTemplate>
            <uc1:UC_AjaxLoading ID="UC_AjaxLoading1" runat="server" />
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table id="NavigationPath">
                <tr>
                    <td>
                        <a href="Manage.aspx"><span>投票主题管理</span></a> | <a href="Add.aspx"><span>添加投票主题</span></a>
                    </td>
                </tr>
            </table>
            <table class="TabelGrid" style="width: 100%">
                <tr>
                    <td class="HeaderStyle" align="center" colspan="2" runat="server" id="UiTitle">
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="RowTitle">
                        投票主题：
                    </td>
                    <td height="25" align="left">
                        <asp:TextBox ID="txtTitle" runat="server" Width="335px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtTitle"
                            ErrorMessage="该项必须填写"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="RowTitle">
                        投票选项：
                    </td>
                    <td height="25" align="left">
                        <table width="100%" class="TabelGrid" id="ChoiceList">
                            <tr class="HeaderStyle">
                                <td>
                                    &nbsp;投票选项
                                </td>
                                <td width="80">
                                    &nbsp;得票数
                                </td>
                                <td width="40" align="center">
                                </td>
                            </tr>
                            <tr id="trSource">
                                <td>
                                    <asp:HiddenField ID="hfID" runat="server" Value="0" />
                                    <asp:TextBox ID="txtChoiceTitle" runat="server" Style="width: 70%" EnableViewState="true"
                                        onblur="CheckChoceTitle(this);" onkeyup="CheckChoceTitle(this);" onkeypress="CheckChoceTitle(this);"></asp:TextBox>
                                </td>
                                <td width="80" align="center">
                                    <WinnerCMS:NumericTextBox ID="NtxtVoteNum" runat="server" Width="80" EnableViewState="true">0</WinnerCMS:NumericTextBox>
                                </td>
                                <td width="40" align="center">
                                    <input name="btnDel" onclick="return DeleteChoice(-1,this)" value="删除" class="btn btn-default" type="button" />
                                </td>
                            </tr>
                        </table>
                        <input id="btnAddChoice" class="btn btn-default" type="button" value="新添选项" onclick="AddChoice();" />
                        <div id="newChoiceLists">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="RowTitle">
                        是否通过审核：
                    </td>
                    <td height="25" align="left">
                        <asp:CheckBox ID="cbkPass" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="RowTitle">
                        选取方式：
                    </td>
                    <td height="25" align="left">
                        <asp:RadioButtonList ID="RBL_SingleSelect" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
                            <asp:ListItem Selected="True" Value="1">单选</asp:ListItem>
                            <asp:ListItem Value="0">多选</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="RowTitle">
                        过期：
                    </td>
                    <td height="25" align="left">
                        <asp:TextBox ID="txtEndData" runat="server" CssClass="date"></asp:TextBox>
                        如果不需要过期，请选择一个很大的日期
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="RowTitle">
                        限制IP：
                    </td>
                    <td height="25" align="left">
                        <asp:CheckBox ID="cbkLimitIP" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="RowTitle">
                        选用模板：
                    </td>
                    <td height="25" align="left">
                        <asp:DropDownList ID="ddlTemplate" runat="server">
                            <asp:ListItem Value="">&lt;默认&gt;</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="RowTitle">
                        &nbsp;
                    </td>
                    <td height="25" align="left">
                        <asp:Button ID="btnOK" runat="server" Cssclass="btn btn-default" EnableTheming="False" EnableViewState="False"
                            Text="确定" OnClick="btnAddChoice_Click" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
